/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;
import javafx.scene.Group;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.control.Label;
import javafx.scene.text.Font;
import javafx.scene.shape.StrokeLineCap;
import javafx.scene.layout.LayoutInfo;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.geometry.HPos;
import javafx.geometry.VPos;
import javafx.scene.Cursor;
import javafx.scene.text.TextAlignment;

/**
 * @author Sik
 */
 public def DEFAULT_COLOR : Color = Color.web("#883300");

public class InnerMenu extends Group
{
    public var width = 140;
    public var height = 40;
    public var text : String;
    public var fontSize : Number = 20;
    public-read var isActive : Boolean;
    public var color : Color;
    public var customCursor : Cursor;
    
    var fillGrad = bind LinearGradient
    {
        startX: 0.0, startY: 0.0, endX: 0.0, endY: 1.0
        proportional: true
        stops: [ Stop { offset: 0.0 color: color },
                 Stop { offset: 1.0 color: Color.BLACK } ]
    }

    public var case : Rectangle =
    bind Rectangle
    {
        height: height
        width: width
        arcWidth: 20 arcHeight: 20
        fill: fillGrad
        stroke: Color.WHITESMOKE
        strokeWidth: 3
        strokeLineCap: StrokeLineCap.ROUND
        cursor: customCursor
    }

    public var txt : Label =
    Label
    {
        layoutInfo: LayoutInfo
        {
            width: width
            height: height
        }

        text: bind text
        textFill: Color.WHITE
        font : bind Font
        {
            name: "Impact"
            size: fontSize
        }
        hpos: HPos.CENTER
        vpos: VPos.CENTER
    }

    public function setActive(activated : Boolean) : Void
    {
        if(activated)
        {
            this.opacity = 1;
            isActive = true;
            this.visible = true;
        }
        else
        {
            this.opacity = 0.5;
            isActive = false;
        }
    }
    
    init
    {
        content =
            [
                case,
                txt
            ]
    }
}
